home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lantools / blueprnt / bplptdef.asm < prev    next >
Assembly Source File  |  1989-11-27  |  5KB  |  168 lines

  1. ;************************************************************
  2. ;* BP-LAN Remote Printer Installation Utility(BPLPTDEF.ASM) *
  3. ;* by Craig Chaiken                                         *
  4. ;* November 28, 1989                                        *
  5. ;*                                                          *
  6. ;* Function: Installs Remote Network Printer                *
  7. ;*                                                          *
  8. ;* Command Format:                                          *
  9. ;*     BPLPTDEF /socket_num /local_printer /remote_printer  *
  10. ;*              /time_out                                   *
  11. ;************************************************************
  12. ;
  13. codeseg segment
  14.         assume  cs:codeseg,ds:codeseg,es:codeseg
  15.         org     100h
  16.  
  17. start:  jmp     intinst
  18.         include bpbioshd.mod
  19.     include    misc.mod
  20.  
  21. ;*** Variables ***
  22. ;
  23. old_int17h_vector  label   dword
  24. old_int17h_offs dw      ?
  25. old_int17h_seg  dw      ?
  26. old_int21h_vector  label   dword
  27. old_int21h_offs dw      ?
  28. old_int21h_seg  dw      ?
  29. socket_num      db      0
  30. local_printer   db      0
  31. remote_printer  db      0
  32. packet_buffer   db      6 dup (0)
  33. time_out        db      40      ;40 seconds of retrying for busy printer
  34. retry_count     db      ?
  35.  
  36. ;*****************************
  37. ;*** New Interrupt Handler ***
  38. ;*****************************
  39. new_int17h      proc    far
  40.         cmp     dl,cs:local_printer
  41.         jz      new_1
  42.         jmp     cs:old_int17h_vector
  43. new_1:  push    bx
  44.         push    cx
  45.         push    dx
  46.         push    si
  47.         push    di
  48.         push    ds
  49.         push    es
  50.         push    ax
  51.  
  52.         push    cs              ;Copy CS into DS
  53.         pop     ds
  54.         mov     cl,time_out
  55.         shr     cl,1
  56.         mov     retry_count,cl  ;retry count=time_out / 2
  57.         mov     cx,4
  58.         cmp     ah,0
  59.         jz      new_2
  60.         dec     cx
  61. new_2:  mov     packet_buffer,'P'
  62.         mov     packet_buffer+1,ah
  63.         mov     ah,remote_printer
  64.         mov     packet_buffer+2,ah
  65.         mov     packet_buffer+3,al
  66.         put_packet      socket_num,cx,offset packet_buffer
  67.         get_packet      socket_num,cx,offset packet_buffer
  68.         cmp     packet_buffer,255
  69.         jnz     new_3
  70.         call    wait_a_sec
  71.         call    wait_a_sec
  72.         dec     retry_count
  73.         jnz     new_2
  74. new_3:  pop     ax
  75.         mov     ah,packet_buffer
  76.         pop     es
  77.         pop     ds
  78.         pop     di
  79.         pop     si
  80.         pop     dx
  81.         pop     cx
  82.         pop     bx
  83.         iret
  84. new_int17h      endp
  85.  
  86. new_int21h      proc    far
  87.         pushf
  88.         cmp     ah,40h          ;writing to device
  89.         jz      new_i2
  90.         popf
  91.         jmp     cs:old_int21h_vector
  92. new_i2: cmp     bx,4            ;printer handle?
  93.         jz      new_i3
  94.         popf
  95.         jmp     cs:old_int21h_vector
  96. new_i3: cmp     cs:remote_printer,0     ;LPT1?
  97.         jz      new_i4
  98.         popf
  99.         jmp     cs:old_int21h_vector
  100. new_i4: cld
  101.         push    cx
  102.         push    dx
  103.         push    si
  104.         xor     dx,dx
  105.         jcxz    new_i6
  106. new_i5: lodsb
  107.         mov     ah,0
  108.         int     17h
  109.         loop    new_i5
  110. new_i6: pop     si
  111.         pop     dx
  112.         pop     cx
  113.         mov     ax,cx
  114.         popf
  115.         clc
  116.         sti
  117.         ret     2
  118. new_int21h      endp
  119.  
  120. ;*************************************
  121. ;*** Install New Interrupt Handler ***
  122. ;*************************************
  123. intinst proc    near
  124.         mov     al,cs:[80h]
  125.         or      al,al
  126.         jz      default
  127.         mov     si,81h
  128.         call    get_opt ;get socket_num
  129.         jb      default
  130.         mov     socket_num,cl
  131.         call    get_opt ;get local printer number
  132.         jb      default
  133.         mov     local_printer,cl
  134.         call    get_opt ;get remote printer number
  135.         jb      default
  136.         mov     remote_printer,cl
  137.         call    get_opt ;get time out in seconds
  138.         jb      default
  139.         mov     time_out,cl
  140. default: mov    ah,35h          ; get interrupt vector function
  141.         mov     al,17h
  142.         int     21h
  143.         mov     old_int17h_offs,bx ; save old interrupt
  144.         mov     old_int17h_seg,es       ;   address
  145.         mov     ah,25h                  ; set interrupt vector function
  146.         mov     al,17h
  147.         mov     dx,offset new_int17h    ; point to new routine
  148.         int     21h
  149.         mov     ah,35h          ; get interrupt vector function
  150.         mov     al,21h
  151.         int     21h
  152.         mov     old_int21h_offs,bx ; save old interrupt
  153.         mov     old_int21h_seg,es       ;   address
  154.         mov     ah,25h                  ; set interrupt vector function
  155.         mov     al,21h
  156.         mov     dx,offset new_int21h    ; point to new routine
  157.         int     21h
  158.         lea     dx,intinst
  159.         int     27h
  160. intinst endp
  161.  
  162. codeseg ends
  163.         end     start
  164.  
  165. ;************************************************************
  166. ;* End of Interrupt Handler Installation Module             *
  167. ;************************************************************
  168.